package com.prs.crm.dao.warning.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.warning.AutoCodeDao;
import com.prs.crm.domain.warning.AutoCode;

/**
 * @author JohnLan
 * @time：2012-11-29 
 * @version 1.0
 * 类说明
 */

public class AutoCodeDaoImpl extends BaseDaoImpl<AutoCode> implements
		AutoCodeDao {
	/**
	 * 查询
	 */
	@SuppressWarnings("unchecked")
	public AutoCode getTaskRemind(final String type) {
		return (AutoCode)getHibernateTemplate().execute(   
			      new HibernateCallback() {  
					@Override
					public Object doInHibernate(Session session) throws HibernateException {   
						Criteria criteria = session.createCriteria(AutoCode.class);
						criteria.add(Restrictions.eq("codeType",type));	//没有进行提醒	
						List<AutoCode> result = criteria.list();
			        	if(result.size()==0){
			        		return null;
			        	}else{
			        		return result.get(0);
			        	}
				}});
		}
	} 

